using Admin2025.Application.Dtos;
using Admin2025.Application.Common;
using Microsoft.AspNetCore.Http;

namespace Admin2025.Application.Services;

/// <summary>
/// 文件上传服务接口
/// </summary>
public interface IFileUploadService
{
    /// <summary>
    /// 验证上传文件
    /// </summary>
    /// <param name="file">上传的文件</param>
    /// <returns>验证结果</returns>
    Task<FileValidationResultDto> ValidateFileAsync(IFormFile file);

    /// <summary>
    /// 上传单个文件
    /// </summary>
    /// <param name="file">上传的文件</param>
    /// <param name="category">文件分类（可选）</param>
    /// <returns>上传结果</returns>
    Task<ApiResult<FileUploadResultDto>> UploadFileAsync(IFormFile file, string? category = null);

    /// <summary>
    /// 批量上传文件
    /// </summary>
    /// <param name="files">上传的文件列表</param>
    /// <param name="category">文件分类（可选）</param>
    /// <returns>批量上传结果</returns>
    Task<ApiResult<BatchUploadResultDto>> UploadFilesAsync(IFormFileCollection files, string? category = null);

    /// <summary>
    /// 删除文件
    /// </summary>
    /// <param name="fileId">文件ID</param>
    /// <returns>删除结果</returns>
    Task<ApiResult<bool>> DeleteFileAsync(string fileId);

    /// <summary>
    /// 获取文件信息
    /// </summary>
    /// <param name="fileId">文件ID</param>
    /// <returns>文件信息</returns>
    Task<ApiResult<FileUploadResultDto>> GetFileInfoAsync(string fileId);

    /// <summary>
    /// 生成缩略图
    /// </summary>
    /// <param name="sourceFilePath">源文件路径</param>
    /// <param name="thumbnailFilePath">缩略图保存路径</param>
    /// <param name="width">宽度</param>
    /// <param name="height">高度</param>
    /// <returns>是否成功</returns>
    Task<bool> GenerateThumbnailAsync(string sourceFilePath, string thumbnailFilePath, int width, int height);

    /// <summary>
    /// 获取文件访问URL
    /// </summary>
    /// <param name="relativePath">相对路径</param>
    /// <returns>完整URL</returns>
    string GetFileUrl(string relativePath);

    /// <summary>
    /// 清理过期临时文件
    /// </summary>
    /// <param name="expireDays">过期天数</param>
    /// <returns>清理的文件数量</returns>
    Task<int> CleanupExpiredFilesAsync(int expireDays = 7);
}
